package cn.wolfcode.wolf2w.job;

import cn.wolfcode.wolf2w.cache.service.IStrategyStatisVORedisService;
import cn.wolfcode.wolf2w.cache.vo.StrategyStatisVO;
import cn.wolfcode.wolf2w.service.IStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * redis数据持久化任务
 */
//@Component
public class RedisDataPersistenceJob {
    @Autowired
    private IStrategyStatisVORedisService strategyStatisVORedisService;
    @Autowired
    private IStrategyService strategyService;
    //定时任务标签
    //cron 任务计划表达式
    @Scheduled(cron = "0/10 * * * * ? ")
    public void dowork() {
        System.out.println("------vo持久化--开始--------------");
        //查询redis 中所有vo对象
        List<StrategyStatisVO> vos =strategyStatisVORedisService.queryStrategyVoByPattern("*");
        for (StrategyStatisVO vo : vos) {
            strategyService.updateStrategyVo(vo);
        }
        System.out.println("------vo持久化--结束--------------");
    }
}
